vorpal_src = [
    'src/Assembler.h',
    'src/Assembler.cpp',
    'src/Compiler.h',
    'src/Compiler.cpp',
    'src/Messages.h',
    'src/Messages.cpp',
    'src/Handle.h',
    'src/Handle.cpp',
    'src/Instructions.h',
    'src/Instructions.cpp',
    'src/Slots.h',
    'src/Slots.cpp',
    'src/Objects.h',
    'src/Objects.cpp',
    'src/ErrorCodes.h',
    'src/ErrorCodes.cpp',
    'src/Common.h',
    'src/Common.cpp',
    'src/Lexer.h',
    'src/Lexer.cpp',
    'src/VM.h',
    'src/VM.cpp',
    'src/VmGroup.h',
    'src/VmGroup.cpp',
    
    'extra/Extras.cpp',
]

vorpal_shell_src = [
	'tools/main-vorpal.cpp', 
	'src/System.h',
	'src/System.cpp',
	'tools/Options.h',
	'tools/Options.cpp',
	'tools/thrpool/src/sll.hh',
	'tools/thrpool/src/TThread.cc',
	'tools/thrpool/src/TThread.hh',
	'tools/thrpool/src/TThreadPool.cc',
	'tools/thrpool/src/TThreadPool.hh',
]

tulgey_src = [
	'tulgey/atto.cpp',
	'tulgey/main-tulgey.cpp',
	'tulgey/atto_internals.cpp',
	'tulgey/atto.h',
	'tulgey/atto_internals.h',
	'tulgey/GameSystem.h',
	'tulgey/GameSystem.cpp',
	'src/System.h',
	'src/System.cpp',
	'tools/thrpool/src/sll.hh',
	'tools/thrpool/src/TThread.cc',
	'tools/thrpool/src/TThread.hh',
	'tools/thrpool/src/TThreadPool.cc',
	'tools/thrpool/src/TThreadPool.hh',
]

inc_flags = ' -Isrc -Itools/thrpool/src '
obj_path = 'obj/debug/'

# TODO: should not have "-arch i386" here!
def Console(product, parts):
	if type(parts) != type([]):
		parts = [ parts ]
	return {	'action': CppApplication,
				'cppflags': ' -O3 -arch i386 -g -Wall -D_REENTRANT ' + inc_flags,
				'ldflags': ' -arch i386 -lpthread',
				'obj_path': obj_path,
				'product': product,
				'parts': parts, 
			}

def Fltk(product, parts):
	print("FLTK BUILDER")
	if type(parts) != type([]):
		parts = [ parts ]
	return {	'action': CppApplication,
				'options': { 'gui': True },
				'cppflags': ' -arch i386 -g -Wall -D_REENTRANT ' + inc_flags + Shell('fltk-config --cxxflags'),
				'ldflags': ' -arch i386 -lpthread ' + Shell('fltk-config --ldflags --use-images'),
				'obj_path': obj_path,
				'product': product,
				'parts': parts, 
			}

targets = {
	'vorpal': { 'subtargets': [ 'messages', 'vorpal_shell' ] },
	'vorpal_shell': { 'builder': Console('bin/vorpal', vorpal_src + vorpal_shell_src ) },
	'messages': { 'builder': Console('bin/mgen', [ 'src/ErrorCodes.cpp', 'src/Common.cpp', 'tools/message-gen.cpp' ]), 'new': [ 'bin/mgen src/Messages.h' ] },
	#'tulgey': { 'builder': Fltk('bin/tulgey', vorpal_src + tulgey_src), 'suffix': [ './mac.sh bin/tulgey' ]  },
	'all': { 'subtargets': [ 'vorpal' ] }, #, 'tulgey' ] },
	'test': { 'subtargets': [ 'all' ], 'suffix': [ './test' ] },
	'clean': { 'prefix': [ 'rm -f obj/null/*', 'rm -f ' + obj_path + '*', 'rm -f bin/*'] },
}
